﻿using System;
using System.ComponentModel;
using System.Windows;

namespace Gmantis.Controls.Chart
{
    [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
    public interface IRenderer
    {
        // Events
        event EventHandler Changed;
        event EventHandler Rendered;

        // Methods
        void AddSeries(IDataSeriesInfo seriesInfo);
        void Clear();

        // Properties
        ICoordConverter CoordConverter { get; set; }
        bool Dirty { get; set; }
        string Options { get; set; }
        UIElement Visual { get; set; }
    }

    internal enum AxisStyle
    {
        None,
        Cartesian,
        Radar
    }

    public enum LabelAlignment
    {
        Auto,
        BottomCenter,
        BottomLeft,
        BottomRight,
        MiddleCenter,
        MiddleLeft,
        MiddleRight,
        TopCenter,
        TopLeft,
        TopRight
    }

    internal interface IView2DRenderer : IRenderer
    {
        // Methods
        UIElement[] Generate();
        Rect Measure(Size sz);

        // Properties
        AxisStyle Axis { get; }
    }

    internal class Renderers
    {
        // Fields
        private PieRenderer _p2;
        private Renderer2D _r2;
        private RadarRenderer _rr;

        // Methods
        public IRenderer GetRenderer(string name)
        {
            switch (name)
            {
                case "Renderer2D":
                    return this.Renderer2D;

                case "Pie":
                    return this.Pie;

                case "Radar":
                    return this.Radar;
            }
            return null;
        }

        // Properties
        public PieRenderer Pie
        {
            get
            {
                if (this._p2 == null)
                {
                    this._p2 = new PieRenderer();
                }
                return this._p2;
            }
        }

        public RadarRenderer Radar
        {
            get
            {
                if (this._rr == null)
                {
                    this._rr = new RadarRenderer();
                }
                return this._rr;
            }
        }

        public Renderer2D Renderer2D
        {
            get
            {
                if (this._r2 == null)
                {
                    this._r2 = new Renderer2D();
                }
                return this._r2;
            }
        }
    }
}
